
function [autocorr] = expan_autolag(func,lag)

len = length(lag);
tam = length(func);
autocorr(1) = (sum(func.*func))/tam;

for i=2:len
    %aux = [func((len-i+2):len); func(1:((len-i+2)-1))];
    aux = [lag(len-(i-2):len); func(1:(tam-i+1))];
    autocorr(i) = (sum(aux.* func)); 
end